﻿using System;
using System.Runtime.InteropServices;
using Tsanie.ShellExt.Definitions;

namespace Tsanie.ShellExt.ContextMenu
{
    public class TextProvider : ContextMenuBaseProvider
    {
        public override string ProviderName { get { return "ContextMenu.Text"; } }
        public override ProviderType Type { get { return ProviderType.ContextMenu; } }
        public override string[] Exts { get { return new[] { ".txt" }; } }
        public override string Creator { get { return "Tsanie"; } }

        public override MenuItem[] GetMenuItems(string[] files)
        {
            this.files = files;
            if (m_Items == null)
            {
                m_Items = new MenuItem[3];
                m_Items[0] = new MenuItem { IsSeparator = true };
                m_Items[1] = new MenuItem
                {
                    Text = "Text file test...",
                    OnClick = new EventHandler(test_Click)
                };
                m_Items[2] = new MenuItem { IsSeparator = true };
            }
            return m_Items;
        }


        string[] files = null;
        [DllImport("User32.dll")]
        public static extern int MessageBox(int hWnd, string lpText, string lpCaption, int uType);

        MenuItem[] m_Items = null;

        void test_Click(object sender, EventArgs e)
        {
            string str = null;
            foreach (string file in files)
            {
                str += file + ", ";
            }
            MessageBox(0, str, "Text", 4);
        }
    }
}
